﻿#include <QFile>
#include <QDir>
#include <QDebug>
#include "imagewriterworker.h"

ImageWriterWorker::ImageWriterWorker(QObject *parent) : QObject(parent) {
}

void ImageWriterWorker::writeFrame(FrameData frame) {
    QString fileName = QString("frames/frame_%1.raw")
                           .arg(frame.frameIndex, 5, 10, QChar('0'));
    QFile file(fileName);
    if (file.open(QIODevice::WriteOnly)) {
        file.write(frame.rawData);
        file.close();
        if(frame.frameIndex%100==0)
        {
            qDebug()<<__FUNCTION__<<__LINE__<<fileName;
        }

    } else {
        qWarning() << "Failed to write file:" << fileName;
    }
}

